<template>
	<view class="content">
		<view class="header">
			<u-navbar 
			:border-bottom='false' 
			back-icon-color="#ffffff" 
			title-color="#ffffff" 
			:background="{background:'transparent'}" 
			back-text="" title="我的团队"></u-navbar>
			<view class="header_top">
				<view class="lf">
					<view class="title">今日流水</view>
					<view class="usdt">{{tdluishui}}</view>
				</view>
				<!-- <view class="lf">
					<view class="title">直推人数</view>
					<view class="usdt">{{zhituinum}}</view>
				</view>
				<view class="lr">
					<view class="title">团队人数</view>
					<view class="usdt">{{tuanduinum}}</view>
				</view> -->
			</view>
		</view>
		<view class="team_list">
			<view class="item_title">
				<view class="name">用户昵称</view>
				<view class="type">类型</view>
				<view class="time">加入时间</view>
			</view>
			<view class="item" v-for="item in user_list" :key="item.id">
				<view class="name">{{item.name}}</view>
				<view class="type">{{item.userlevelname}}</view>
				<view class="time">{{item.create_time}}</view>
			</view>
			<view class="msg" :class="{order_null:user_list.length<=0}">
				<u-empty v-if="user_list.length<=0" text="暂无团队成员" mode="list"></u-empty>
				<u-loadmore :status="status" />
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				user_list:[],
				page:1,//当前页码
				list_rows:10,//每页数量
				total:0,//数据总量
				zhituinum:0,//直推人数
				tuanduinum:0,//团队人数
				tdluishui:0,//今日流水
			}
		},
		onReady() {
			
		},
		onLoad() {
			this.getList()
		},
		onPullDownRefresh(){
			this.user_list = []
			this.page=1
			this.getList()
		},
		onReachBottom(){
			if(Math.ceil(this.total/this.list_rows)>this.page){
				this.page = this.page+1
				this.getList()
			}else{
				
			}
		},
		methods: {
			//我的团队
			getList(){
				this.status = 'loading'
				this.$http({
					url:this.$api.user_getAll,
					method:'POST',
					hideLoading:false,
					data:{page:this.page,list_rows:this.list_rows},
					success:res=>{
						
						//console.log('成功返回---------',res)
						this.total = res.data.total
						this.zhituinum = res.data.zhituinum
						this.tuanduinum = res.data.tuanduinum
						this.tdluishui = res.data.tdluishui
						if(Math.ceil(this.total/this.list_rows)<=this.page){
							this.status = 'nomore'
						}else{
							this.status = 'loadmore'
						}
						this.user_list = this.user_list.concat(res.data.data)
					},
					fail:err=>{
						this.status = 'nomore'
					},
					complete:e=>{
						uni.stopPullDownRefresh();
						if(!e.code){
							this.status = 'nomore'
						}
					}
				})
			},
		}
	}
</script>
<style lang="scss" scoped>
	.content{
		.header{
			background:url(../../static/zz.png)center/cover no-repeat;
			.header_top{
				text-align: center;
				padding: 30rpx 0 20rpx 0;
				box-shadow: 0 5rpx 5rpx rgba(62,9,149,1);
				color: #ffffff;
				display: flex;
				justify-content: center;
				.lf,.lr{
					margin:0 80rpx
				}
				.title{
					color:#999999;
				}
				.usdt{
					font-weight: 600;
					font-size: 18px;
				}
				
			}
			
			
		}
		.team_list{

			.item_title{
				display: flex;
				justify-content: space-between;
				text-align: center;
				font-size: 14px;
				font-weight: 600;
				color: #FFFFFF;
				padding: 42rpx 28rpx 18rpx 28rpx;
				border-bottom: 8rpx solid $border-bottom-color;
				>view{
					width: 40%;
				}
				>view:nth-child(2){
					width: 20%;
				}
				.name{
					text-align: left;
				}
				.time{
					text-align: right;
				}
			}
			.item{
				display: flex;
				justify-content: space-between;
				margin: 0 28rpx;
				padding: 60rpx 0 24rpx;
				color: #FFFFFF;
				font-size: 12px;
				>view{
					width: 40%;
					text-align: center;
					font-weight: 600;
				}
				>view:nth-child(2){
					width: 20%;
				}
				.name{
					text-align: left;
				}
				.type{
					text-align: center;
				}
				.time{
					text-align: right;
					color: #5b6aff;
				}
			}
		}
		.msg{
			padding: 20rpx;
		}
		.order_null{
			position: fixed;
			left: 0%;
			top: 50%;
			width: 100%;
		}
	}
</style>